1. Field of the Invention
The invention generally relates to a progress recording method and a recovering method, and more particularly, to a progress recording method and a recovering method adapted to an encoding operation performed on a storage device.
2. Description of Related Art
A hard disk is an essential storage device used in a computer. Hard disks are broadly adopted by notebook computers, desktop computers, and specialty servers for storing large amounts of data. Generally, a hard disk is divided into one or more storage areas (partitions or volumes), and each storage area is used for installing an operating system or storing data.
Besides the general data reading and writing operations, other encoding operations, such as encryption, decryption, re-encryption, and reverse re-encryption, can also be performed on the storage areas of a hard disk. Aforementioned encryption operation requires a corresponding password to be set. An encryption operation can convert data in a storage area from plain text to cipher text to protect the data, while a decryption operation can convert data in the storage area from cipher text back to the original plain text. To change the encryption password, aforementioned re-encryption operation first decrypts the cipher text in the storage area with the old password and then encrypts the data again with the new password. After the re-encryption operation is suspended, the reverse re-encryption operation decrypts the re-encrypted data with the new password and then encrypts it with the old password, so that the data in the storage area is restored to its state before the re-encryption.
The hard disk in a large-scale server usually stores a great mass of data. Accordingly, an encryption operation may take several days, and the possibility of contingencies (for example, power failures) may be drastically increased. If a power failure occurs during an encryption operation, data in a storage area may be damaged or lost, or the entire storage area may become inaccessible.
A conventional encoding operation sets a header in a storage area for storing an offset. Herein the offset indicates the progress of the encoding operation. The offset is updated every time after a specific amount of data (for example, data of 32 megabytes (MB) is encoded. However, such a technique cannot effectively avoid the problem of data loss caused by power failures.
FIG. 1 is a diagram illustrating an encoding operation performed on a storage area 100 of a hard disk. The header 120 of the storage area 100 stores aforementioned offset, and this offset is updated every time after data of b bytes is encoded. The encoding operation is performed from the offset S to the offset 0. Herein b and S are predetermined constants. When the encoding operation reaches the offset S-b, the offset stored in the header 120 is updated. If no contingency occurs, when the encoding operation reaches the offset S-2b, the offset stored in the header 120 is updated again. However, if a power failure occurs when the encoding operation reaches the offset p and the encoding operation is resumed from the offset S-b according to the value stored in the header 120 after the power is resupplied, data from the offset S-b to the offset p is encoded twice. Namely, the data is damaged.